package assignment.ton.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JPanel;

import assignment.ton.def.Util;
import assignment.ton.gui.listener.MenuActionListener;
/**
 * The menu panel on the left,also creates the sub panel for when a class is selected
 * @author Tim
 */
public class MenuPanel extends JPanel{
	private static final long serialVersionUID = 1L;
	private JButton addClass, cancelButton;
	private MenuActionListener menuListener;
	private VisibleSelectedPanel selectedPanel;
	private MainFrame mainFrame;
	public MenuPanel(MainFrame mF){
		mainFrame = mF;
		addClass = new JButton("Add Class");
		selectedPanel = new VisibleSelectedPanel(mainFrame);
		menuListener = new MenuActionListener(mainFrame);
		this.add(addClass, BorderLayout.NORTH);
		addClass.addActionListener(menuListener);
		cancelButton = new JButton("   Cancel   ");
		cancelButton.setActionCommand("Cancel");
		this.add(cancelButton, BorderLayout.CENTER);
		cancelButton.addActionListener(menuListener);
		this.add(selectedPanel,BorderLayout.SOUTH);
		this.setVisible(true);
		this.setPreferredSize(new Dimension(118,300));
		this.setMaximumSize(new Dimension(118,300));
		this.setBackground(Util.background());
	}
	public void setTheSize(Dimension d){
		this.setPreferredSize(d);
	}
	public void setSelectedVisible(boolean b){
		selectedPanel.setVisible(b);
	}
}
